package cn.iocoder.yudao.module.tms.controller.admin.statistics;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.tms.controller.admin.statistics.vo.*;
import cn.iocoder.yudao.module.tms.service.statistics.StatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * TMS统计分析 Controller
 *
 * @author 芋道源码
 */
@Tag(name = "管理后台 - TMS统计分析")
@RestController
@RequestMapping("/tms/statistics")
@Validated
public class StatisticsController {

    @Resource
    private StatisticsService statisticsService;

    @GetMapping("/overview")
    @Operation(summary = "获取统计概览")
    @PreAuthorize("@ss.hasPermission('tms:statistics:query')")
    public CommonResult<StatisticsOverviewVO> getStatisticsOverview(@Valid StatisticsQueryReqVO reqVO) {
        StatisticsOverviewVO overview = statisticsService.getStatisticsOverview(reqVO);
        return success(overview);
    }

    @GetMapping("/band-usage")
    @Operation(summary = "获取Band使用统计")
    @PreAuthorize("@ss.hasPermission('tms:statistics:query')")
    public CommonResult<List<BandUsageStatisticsVO>> getBandUsageStatistics(@Valid StatisticsQueryReqVO reqVO) {
        List<BandUsageStatisticsVO> list = statisticsService.getBandUsageStatistics(reqVO);
        return success(list);
    }

    @GetMapping("/band-inspection")
    @Operation(summary = "获取Band查验统计")
    @PreAuthorize("@ss.hasPermission('tms:statistics:query')")
    public CommonResult<List<BandInspectionStatisticsVO>> getBandInspectionStatistics(@Valid StatisticsQueryReqVO reqVO) {
        List<BandInspectionStatisticsVO> list = statisticsService.getBandInspectionStatistics(reqVO);
        return success(list);
    }

    @GetMapping("/order-inspection")
    @Operation(summary = "获取订单查验统计")
    @PreAuthorize("@ss.hasPermission('tms:statistics:query')")
    public CommonResult<List<OrderInspectionStatisticsVO>> getOrderInspectionStatistics(@Valid StatisticsQueryReqVO reqVO) {
        List<OrderInspectionStatisticsVO> list = statisticsService.getOrderInspectionStatistics(reqVO);
        return success(list);
    }

    @GetMapping("/customer-cooperation")
    @Operation(summary = "获取客户合作统计")
    @PreAuthorize("@ss.hasPermission('tms:statistics:query')")
    public CommonResult<List<CustomerCooperationStatisticsVO>> getCustomerCooperationStatistics(@Valid StatisticsQueryReqVO reqVO) {
        List<CustomerCooperationStatisticsVO> list = statisticsService.getCustomerCooperationStatistics(reqVO);
        return success(list);
    }
}
